02. Updating a Todo Item: Part I

Implement Updating a Todo Item

ND004 C01 L07 02 Update A Todo Item- The “U” In CRUD

Takeaways

An update involves setting the attributes of an existing object in the database.

In SQL:

UPDATE table_name
SET column1 = value1, column2 = value2, ...
WHERE condition;

In SQLAlchemy ORM:

user = User.query.get(some_id)
user.name = 'Some new name'
db.session.commit()

Using the Jinja if statement

ND004 C01 L07 03 Update Todo Item Walk-Through

Check out the Jinja Docs

Click here for the Jinja Docs

Next up: adding update functionality to our Todo App

Feel free to use the interactive workspace below to follow along the walk-throughs ahead in this lesson in adding update functionality to your Todo app. Have this page open in a separate tab or window, so you can continue to use it throughout the concepts in this lesson.

Starter Code

Click here: todoapp-migrations.zip

Workspace

This section contains either a workspace (it can be a Jupyter Notebook workspace or an online code editor work space, etc.) and it cannot be automatically downloaded to be generated here. Please access the classroom with your account and manually download the workspace to your local machine. Note that for some courses, Udacity upload the workspace files onto https://github.com/udacity , so you may be able to download them there.

Workspace Information:

  • Default file path:
  • Workspace type: jupyter-lab
  • Opened files (when workspace is loaded): n/a

Walk-throughs

Modifying the view in index.html to show checkboxes

ND004 C01 L07 03.1 Update Todo Item Walk-Through

Having the checkboxes send off update ( POST ) requests

ND004 C01 L07 03.2 Update Todo Item Walk-Through